<%@page contentType="text/html; charset=utf-8" %>
<%@ include file="/commons/taglibs.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/common/prototype.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/common.js"></script>
<%@include file="/commons/commonList.jsp" %>
<%@include file="coWorkerSelectInclude.jsp" %>
<script type="text/javascript">
	var selectedId = null;

	var idSerials = null;

	function openSelect(){
		var url = "${ctx}/house_projectAction.do?method=initCoWorkerUnSelected&coWorkerType=${coWorkerType}";
		top.windowOpen(url,"coworkUnSelectForm","${title}",300,700,true,"coworkUnSelectFrame");
	}

	function openDelete(){
		//没有选择记录，提示选择条记录
		if(selectedId == null || selectedId == ""){
			ErrorAlert("${key.tipsByDelete}");
			return;
		}
		AskConfirm("${key.tipsByDeleteConfirm}","${coWorkerType}" + 'SelectFrame',"_delete");
	}
	function _delete(){
		var url = "${ctx}/house_projectAction.do?method=deleteCoWorkerById";
		var str = "coWorkerType=${coWorkerType}&coWorkId=" + selectedId;
		new Ajax.Request(url,
	                  {method: 'post', parameters: str, onComplete:function(){
	                  										parent.reloadFrame("${coWorkerType}");
	                  							}
	                  }
	                  );
	}

	function getSelectedIds(){
		var getSelecIdsUrl = "${ctx}/house_projectAction.do?method=getCoWorkerIds";
		var workType = "coworkType=${coWorkerType}";
		var tempVar = "";
		new Ajax.Request(getSelecIdsUrl,
	                  {method: 'post',
	                  	parameters: workType,
	                  	asynchronous:false,
	                  	onComplete:function(result){
	                  		tempVar = result.responseText;
	                  	}
	                  }
	                  );
	    return tempVar;
	}
	function init(){
	   if(parent.initSelectIdsStatus)  return; //如果parent.initSelectIdsStatus为真,则说明初始化过了。
		<c:if test="${coWorkerType eq 'developer'}"> parent.developerIds = getSelectedIds();</c:if>
		<c:if test="${coWorkerType eq 'design'}">parent.designIds = getSelectedIds();</c:if>
		<c:if test="${coWorkerType eq 'construction'}">parent.constructionIds = getSelectedIds();</c:if>
		<c:if test="${coWorkerType eq 'supervision'}">parent.supervisionIds = getSelectedIds();</c:if>
		//修改标识，说明已经初始化过了
		if(parent.developerIds != null && parent.designIds != null && parent.constructionIds != null && parent.supervisionIds != null)
			parent.initSelectIdsStatus = true;
	}
</script>
</head>
<body onload="init();">
<table width="100%" border="0" cellspacing="0" cellpadding="0" >
    <tr>
      <td class="bg_toolBar"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="35%" align="right"><table border="0" cellpadding="0" cellspacing="0" id="ico1">
                <tr>
                  <td class="toolbarico"><a href="#"  onclick="openSelect();" onfocus="this.blur()"><img src="${ctx}/images/ico_newfile.gif" border="0" align="absbottom" alt="新增"/>&nbsp;</a></td>

                  <td class="toolbarico"><a href="#" onClick="openDelete();" onFocus="this.blur()"><img src="${ctx}/images/ico_delete.gif" alt="删除" width="16" height="16" border="0" align="absbottom"></a></td>
                  <td  class="toolbarico">&nbsp;</td>
                </tr>
            </table></td>
          </tr>
      </table></td>
    </tr>
    <tr>
      <td colspan="5" >
	<ec:ceTable items="coworks"
				autoIncludeParameters="true"
				var="coworkItem"
				tableId="ec"
				action=""
				rowsDisplayed="3"
				width="100%"
				view="pmsview"
				styleClass="gridData"
			>
			<ec:ceRow styleClass="grid" id="${coworkItem.coWorkerID}" onclick="selectedId='${coworkItem.coWorkerID}'" onContextMenu="return ShowContextMenu(event,'quick_rightmenu')">
				<ec:ceColumn property="name" headerCell="pmsHeadrCell" width="25%" title="${name}"></ec:ceColumn>
				<ec:ceColumn property="contactor" headerCell="pmsHeadrCell"  width="25%"  title="${contactor}"></ec:ceColumn>
				<ec:ceColumn property="address" headerCell="pmsHeadrCell"   width="25%" title="${address}"></ec:ceColumn>
				<ec:ceColumn property="telephone" headerCell="pmsHeadrCell" width="25%" title="${telephone}"></ec:ceColumn>
			</ec:ceRow>
	</ec:ceTable>
      </td>
    </tr>
</table>

	<div id="quick_rightmenu" style="display:none;" oncontextmenu="return false" class="quick_menu2" onMouseOver="showmy2menu('quick_rightmenu')"  onMouseOut="hidden2menu('quick_rightmenu')" >
                      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="grid_quickMenu_bg">
                        <tr>
                          <td><table width="100%" border="0" cellpadding="2" cellspacing="0">
                              <tr>
                                <td class="quickMenu_toolbarico"><a href="#"  onClick="openSelect();" onFocus="this.blur()"><img src="${ctx}/images/ico_newfile.gif" border="0" align="absbottom" alt="新建"/>&nbsp;新 增</a></td>
                              </tr>

                              <tr>
                                <td class="quickMenu_toolbarico"><a href="#" onClick="openDelete();" onFocus="this.blur()"><img src="${ctx}/images/ico_delete.gif" alt="" width="16" height="16" border="0" align="absbottom"> 删
                                  除</a></td>
                              </tr>
                              <tr>
                                <td class="hrpading"><table width="98%" border="0" align="left" cellpadding="0" cellspacing="0">
                                </table></td>
                              </tr>
                          </table></td>
                        </tr>
                      </table>
</div>
</body>
</html>